function levelOrder(root){
    if(!root) return [];
    let queue = [root];
    const res = [];
    while (queue.length > 0){
        const node = queue.shift();
        res.push(node.value)
        if(node.left) queue.push(node.left);
        if(node.right) queue.push(node.right);
    }
    return res;
}
